import request from '@/utils/request'

export function getList() {
  // 请求路径： VUE_APP_BASE_API + /albums
  return request({
    url: '/albums',
    method: 'get'
  })
}

export function getAlbum(id) {
  return request({
    url: `/albums/${id}`,
    method: 'get'
  })
}

export function getCover(albumId) {
  return request({
    url: `/albums/${albumId}/cover`,
    method: 'get'
  })
}

export function setCover(albumId, pictureId) {
  return request({
    url: `/albums/${albumId}/pictures/${pictureId}/set-cover`,
    method: 'post'
  })
}

export function getPictures(albumId) {
  return request({
    url: `/albums/${albumId}/pictures`,
    method: 'get'
  })
}

export function createAlbum(data) {
  return request({
    url: '/albums/add-new',
    method: 'post',
    data
  })
}

export function addPicture(data) {
  return request({
    url: `/albums/pictures/add-new`,
    method: 'post',
    data: data
  })
}

export function deletePicture(albumId, pictureId) {
  return request({
    url: `/albums/${albumId}/pictures/${pictureId}/delete`,
    method: 'post'
  })
}

export function deleteUpload(url) {
  return request({
    url: `/upload/delete`,
    method: 'post',
    data: url
  })
}
